package StudyCode.summary.mycollection;

import java.util.BitSet;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class BitSetBitOperations {
	public static void main(String[] argv) {
		BitSet bits = new BitSet();

		bits.set(2); // 100 = decimal 4
		System.out.println(bits);
		boolean b = bits.get(0); // false
		b = bits.get(2); // true
		System.out.println(b);
		bits.clear(1);
		System.out.println(bits);
		BitSet bits2 = new BitSet();
		bits2.set(1, 4); // 1110
		System.out.println(bits2);
		bits.and(bits2); // 0100
		System.out.println(bits);
		bits.xor(bits2); // 1010
		System.out.println(bits);
		bits.flip(0, bits.length()); // 0101
		System.out.println(bits);
		bits.andNot(bits2); // 0001
		System.out.println(bits);
		bits.or(bits2); // 1111
		System.out.println(bits);
	}
}
